import java.util.*;

/**
 * This class is used for research specific list of publications of an author.
 * 
 */
public class RepoPublications {
	private List<Publications> aPublics;

	/**
	 * Construct a RepoPublications object with a list of publication.
	 * 
	 * @param myPublics The list of publications.
	 */
	public RepoPublications(List<Publications> myPublics) {
		this.aPublics = myPublics;
	}

	/**
	 * Return a list of publications, with ISBN code, for a specific author.
	 * 
	 * @param authorToSearch The specific author.
	 * @return the list of publications with an ISBN code.
	 */
	public List<Publications> getIsbnList(String authorToSearch) {

		List<Publications> myList = new ArrayList<Publications>();
		for (int i = 0; i < aPublics.size(); i++) {
			for (int k = 0; k < aPublics.get(i).getAuthors().size(); k++)
				if (aPublics.get(i).getAuthors().get(k).getName()
						.equalsIgnoreCase(authorToSearch))
					if ((aPublics.get(i).getIsbn() != null))
						myList.add(aPublics.get(i));
		}
		return myList;
	}

	/**
	 * Return a list of publications, with ISSN code, for a specific author.
	 * 
	 * @param authorToSearch The specific author.
	 * @return the list of publications with an ISSN code.
	 */
	public List<Publications> getIssnList(String authorToSearch) {

		List<Publications> myList = new ArrayList<Publications>();
		for (int i = 0; i < aPublics.size(); i++) {
			for (int k = 0; k < aPublics.get(i).getAuthors().size(); k++)
				if (aPublics.get(i).getAuthors().get(k).getName()
						.equalsIgnoreCase(authorToSearch))
					if ((aPublics.get(i).getIssn() != null))
						myList.add(aPublics.get(i));
		}
		return myList;
	}

	/**
	 * Return a list of publications, without code, for a specific author.
	 * 
	 * @param authorToSearch The specific author.
	 * @return the list of publications without code.
	 */
	public List<Publications> getWithoutCodeList(String authorToSearch) {

		List<Publications> myList = new ArrayList<Publications>();
		for (int i = 0; i < aPublics.size(); i++) {
			for (int k = 0; k < aPublics.get(i).getAuthors().size(); k++)
				if (aPublics.get(i).getAuthors().get(k).getName()
						.equalsIgnoreCase(authorToSearch))
					if ((aPublics.get(i).getIsbn() == null)
							&& (aPublics.get(i).getIssn() == null))
						myList.add(aPublics.get(i));
		}
		return myList;
	}
}
